Optimal. Leaf size=186 \[ -\frac{b^2 \sin (e+f x)}{f \left (a^2-b^2\right ) (b c-a d) (a \cos (e+f x)+b)}+\frac{2 b \left (-2 a^2 d+a b c+b^2 d\right ) \tanh ^{-1}\left (\frac{\sqrt{a-b} \tan \left (\frac{1}{2} (e+f x)\right )}{\sqrt{a+b}}\right )}{f (a-b)^{3/2} (a+b)^{3/2} (b c-a d)^2}+\frac{2 d^2 \tanh ^{-1}\left (\frac{\sqrt{c-d} \tan \left (\frac{1}{2} (e+f x)\right )}{\sqrt{c+d}}\right )}{f \sqrt{c-d} \sqrt{c+d} (b c-a d)^2} \]
[Out]
________________________________________________________________________________________
Rubi [A] time = 0.604509, antiderivative size = 186, normalized size of antiderivative = 1., number of steps used = 7, number of rules used = 5, integrand size = 31, \(\frac{\text{number of rules}}{\text{integrand size}}\) = 0.161, Rules used = {3988, 3056, 3001, 2659, 208} \[ -\frac{b^2 \sin (e+f x)}{f \left (a^2-b^2\right ) (b c-a d) (a \cos (e+f x)+b)}+\frac{2 b \left (-2 a^2 d+a b c+b^2 d\right ) \tanh ^{-1}\left (\frac{\sqrt{a-b} \tan \left (\frac{1}{2} (e+f x)\right )}{\sqrt{a+b}}\right )}{f (a-b)^{3/2} (a+b)^{3/2} (b c-a d)^2}+\frac{2 d^2 \tanh ^{-1}\left (\frac{\sqrt{c-d} \tan \left (\frac{1}{2} (e+f x)\right )}{\sqrt{c+d}}\right )}{f \sqrt{c-d} \sqrt{c+d} (b c-a d)^2} \]
Antiderivative was successfully verified.
[In]
[Out]
Rule 3988
Rule 3056
Rule 3001
Rule 2659
Rule 208
Rubi steps
\begin{align*} \int \frac{\sec (e+f x)}{(a+b \sec (e+f x))^2 (c+d \sec (e+f x))} \, dx &=\int \frac{\cos ^2(e+f x)}{(b+a \cos (e+f x))^2 (d+c \cos (e+f x))} \, dx\\ &=-\frac{b^2 \sin (e+f x)}{\left (a^2-b^2\right ) (b c-a d) f (b+a \cos (e+f x))}-\frac{\int \frac{-a b d-\left (a b c-a^2 d+b^2 d\right ) \cos (e+f x)}{(b+a \cos (e+f x)) (d+c \cos (e+f x))} \, dx}{\left (a^2-b^2\right ) (b c-a d)}\\ &=-\frac{b^2 \sin (e+f x)}{\left (a^2-b^2\right ) (b c-a d) f (b+a \cos (e+f x))}+\frac{d^2 \int \frac{1}{d+c \cos (e+f x)} \, dx}{(b c-a d)^2}+\frac{\left (b \left (a b c-2 a^2 d+b^2 d\right )\right ) \int \frac{1}{b+a \cos (e+f x)} \, dx}{\left (a^2-b^2\right ) (b c-a d)^2}\\ &=-\frac{b^2 \sin (e+f x)}{\left (a^2-b^2\right ) (b c-a d) f (b+a \cos (e+f x))}+\frac{\left (2 d^2\right ) \operatorname{Subst}\left (\int \frac{1}{c+d+(-c+d) x^2} \, dx,x,\tan \left (\frac{1}{2} (e+f x)\right )\right )}{(b c-a d)^2 f}+\frac{\left (2 b \left (a b c-2 a^2 d+b^2 d\right )\right ) \operatorname{Subst}\left (\int \frac{1}{a+b+(-a+b) x^2} \, dx,x,\tan \left (\frac{1}{2} (e+f x)\right )\right )}{\left (a^2-b^2\right ) (b c-a d)^2 f}\\ &=\frac{2 b \left (a b c-2 a^2 d+b^2 d\right ) \tanh ^{-1}\left (\frac{\sqrt{a-b} \tan \left (\frac{1}{2} (e+f x)\right )}{\sqrt{a+b}}\right )}{(a-b)^{3/2} (a+b)^{3/2} (b c-a d)^2 f}+\frac{2 d^2 \tanh ^{-1}\left (\frac{\sqrt{c-d} \tan \left (\frac{1}{2} (e+f x)\right )}{\sqrt{c+d}}\right )}{\sqrt{c-d} \sqrt{c+d} (b c-a d)^2 f}-\frac{b^2 \sin (e+f x)}{\left (a^2-b^2\right ) (b c-a d) f (b+a \cos (e+f x))}\\ \end{align*}
Mathematica [A] time = 1.01619, size = 176, normalized size = 0.95 \[ \frac{\frac{2 d^2 \left (a^2-b^2\right ) \tanh ^{-1}\left (\frac{(d-c) \tan \left (\frac{1}{2} (e+f x)\right )}{\sqrt{c^2-d^2}}\right )}{\sqrt{c^2-d^2}}+\frac{2 b \left (-2 a^2 d+a b c+b^2 d\right ) \tanh ^{-1}\left (\frac{(b-a) \tan \left (\frac{1}{2} (e+f x)\right )}{\sqrt{a^2-b^2}}\right )}{\sqrt{a^2-b^2}}+\frac{b^2 (b c-a d) \sin (e+f x)}{a \cos (e+f x)+b}}{f (b-a) (a+b) (b c-a d)^2} \]
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [A] time = 0.105, size = 210, normalized size = 1.1 \begin{align*}{\frac{1}{f} \left ( 2\,{\frac{b}{ \left ( ad-bc \right ) ^{2}} \left ( -{\frac{b \left ( ad-bc \right ) \tan \left ( 1/2\,fx+e/2 \right ) }{ \left ({a}^{2}-{b}^{2} \right ) \left ( \left ( \tan \left ( 1/2\,fx+e/2 \right ) \right ) ^{2}a- \left ( \tan \left ( 1/2\,fx+e/2 \right ) \right ) ^{2}b-a-b \right ) }}-{\frac{2\,{a}^{2}d-abc-{b}^{2}d}{ \left ( a+b \right ) \left ( a-b \right ) \sqrt{ \left ( a+b \right ) \left ( a-b \right ) }}{\it Artanh} \left ({\frac{ \left ( a-b \right ) \tan \left ( 1/2\,fx+e/2 \right ) }{\sqrt{ \left ( a+b \right ) \left ( a-b \right ) }}} \right ) } \right ) }+2\,{\frac{{d}^{2}}{ \left ( ad-bc \right ) ^{2}\sqrt{ \left ( c+d \right ) \left ( c-d \right ) }}{\it Artanh} \left ({\frac{\tan \left ( 1/2\,fx+e/2 \right ) \left ( c-d \right ) }{\sqrt{ \left ( c+d \right ) \left ( c-d \right ) }}} \right ) } \right ) } \end{align*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [F(-2)] time = 0., size = 0, normalized size = 0. \begin{align*} \text{Exception raised: ValueError} \end{align*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [F(-1)] time = 0., size = 0, normalized size = 0. \begin{align*} \text{Timed out} \end{align*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [F(-1)] time = 0., size = 0, normalized size = 0. \begin{align*} \text{Timed out} \end{align*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [B] time = 1.32131, size = 458, normalized size = 2.46 \begin{align*} \frac{2 \,{\left (\frac{{\left (\pi \left \lfloor \frac{f x + e}{2 \, \pi } + \frac{1}{2} \right \rfloor \mathrm{sgn}\left (-2 \, c + 2 \, d\right ) + \arctan \left (-\frac{c \tan \left (\frac{1}{2} \, f x + \frac{1}{2} \, e\right ) - d \tan \left (\frac{1}{2} \, f x + \frac{1}{2} \, e\right )}{\sqrt{-c^{2} + d^{2}}}\right )\right )} d^{2}}{{\left (b^{2} c^{2} - 2 \, a b c d + a^{2} d^{2}\right )} \sqrt{-c^{2} + d^{2}}} + \frac{b^{2} \tan \left (\frac{1}{2} \, f x + \frac{1}{2} \, e\right )}{{\left (a^{2} b c - b^{3} c - a^{3} d + a b^{2} d\right )}{\left (a \tan \left (\frac{1}{2} \, f x + \frac{1}{2} \, e\right )^{2} - b \tan \left (\frac{1}{2} \, f x + \frac{1}{2} \, e\right )^{2} - a - b\right )}} - \frac{{\left (a b^{2} c - 2 \, a^{2} b d + b^{3} d\right )}{\left (\pi \left \lfloor \frac{f x + e}{2 \, \pi } + \frac{1}{2} \right \rfloor \mathrm{sgn}\left (2 \, a - 2 \, b\right ) + \arctan \left (\frac{a \tan \left (\frac{1}{2} \, f x + \frac{1}{2} \, e\right ) - b \tan \left (\frac{1}{2} \, f x + \frac{1}{2} \, e\right )}{\sqrt{-a^{2} + b^{2}}}\right )\right )}}{{\left (a^{2} b^{2} c^{2} - b^{4} c^{2} - 2 \, a^{3} b c d + 2 \, a b^{3} c d + a^{4} d^{2} - a^{2} b^{2} d^{2}\right )} \sqrt{-a^{2} + b^{2}}}\right )}}{f} \end{align*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]